package com.xywang.dao;

import com.xywang.pojo.Books;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.List;

public class BookMapperImpl implements BookMapper{

    private SqlSessionTemplate sqlSessionTemplate;
    public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    @Override
    public int addBook(Books books) {
        return sqlSessionTemplate.getMapper(BookMapper.class).addBook(books);
    }

    @Override
    public int deleteBook(int id) {
        return sqlSessionTemplate.getMapper(BookMapper.class).deleteBook(id);
    }

    @Override
    public int updateBook(Books books) {
        return sqlSessionTemplate.getMapper(BookMapper.class).updateBook(books);
    }

    @Override
    public Books selectBookByID(int id) {
        return sqlSessionTemplate.getMapper(BookMapper.class).selectBookByID(id);
    }

    @Override
    public List<Books> selectAllBooks() {
        return sqlSessionTemplate.getMapper(BookMapper.class).selectAllBooks();
    }

    @Override
    public List<Books> selectBooksByName(String name) {
        return sqlSessionTemplate.getMapper(BookMapper.class).selectBooksByName(name);
    }
}
